<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <meta charset="utf-8">
    <title>后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="favicon.ico">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/index.css" media="all" />
</head>
<body class="main_body">

<script type="text/html" id="editTpl">
    <div style="margin-top: 20px;margin-left: 20px">
        <form class="layui-form layui-form-pane" lay-filter="editFormFilter">
            <div class="layui-form-item">
                <label class="layui-form-label">原密码</label>
                <div class="layui-input-inline">
                    <input type="password" class="layui-input" name="password" placeholder="请输入原密码" lay-verify="required" lay-reqText="原密码"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                    <input type="password" class="layui-input" name="newPassword" placeholder="请输入新密码" lay-verify="required" lay-reqText="请输入新密码"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                    <input type="password" class="layui-input" name="confirmPassword" id="confirmPassword" placeholder="请再次输入新密码" lay-verify="required" lay-reqText="请再次输入新密码"/>
                </div>
            </div>
            <button id="submitBtn" lay-submit lay-filter="submitBtnFilter" style="display: none"></button>
        </form>
    </div>
</script>

<div class="layui-layout layui-layout-admin">
    <!-- 顶部 -->
    <div class="layui-header header">
        <div class="layui-main mag0">
            <a href="javascript:void(0)" class="logo">信息管理系统</a>
            <!-- 显示/隐藏菜单 -->
            <a href="javascript:;" class="seraph hideMenu icon-caidan"></a>

            <!-- 顶部右侧菜单 -->
            <ul class="layui-nav top_menu">
                <li class="layui-nav-item" pc>
                    <a href="javascript:;" class="clearCache"><i class="layui-icon" data-icon="&#xe640;">&#xe640;</i><cite>清除缓存</cite><span class="layui-badge-dot"></span></a>
                </li>
                <li class="layui-nav-item" id="userInfo">
                    <a href="javascript:;"><img src="${pageContext.request.contextPath}/resources/face/${user.img}" onerror="javascript:this.src='${pageContext.request.contextPath}/resources/face/11.png';" class="layui-nav-img userAvatar" width="35" height="35"><cite class="adminName">${user.name}</cite></a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" data-url="${pageContext.request.contextPath}/page/sys/userInfo.do"><i class="seraph icon-ziliao" data-icon="icon-ziliao"></i><cite>个人资料</cite></a></dd>
                        <dd><a class="changePassword" id="changePassword"><i class="seraph icon-xiugai" data-icon="icon-xiugai"></i><cite>修改密码</cite></a></dd>
                        <dd><a href="javascript:;" class="showNotice"><i class="layui-icon">&#xe645;</i><cite>待审核通知</cite><span class="layui-badge" id="payMentNotice">0</span></a></dd>
                        <dd><a class="signOut" id="signOut"><i class="seraph icon-tuichu"></i><cite>退出账号</cite></a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>
    <!-- 左侧导航 -->
    <div class="layui-side layui-bg-black">
        <div class="user-photo">
            <a class="img" title="我的头像" ><img src="${pageContext.request.contextPath}/resources/face/${user.img}" onerror="javascript:this.src='${pageContext.request.contextPath}/resources/face/11.png';" class="userAvatar"></a>
            <p>你好！<span class="userName">${user.name}</span>, 欢迎登录</p>
        </div>
        <div class="navBar layui-side-scroll" id="navBar">
            <ul class="layui-nav layui-nav-tree">
                <li class="layui-nav-item layui-this">
                    <a href="javascript:;" data-url="page/main.html"><i class="layui-icon" data-icon=""></i><cite>后台首页</cite></a>
                </li>
            </ul>
        </div>
    </div>
    <!-- 右侧内容 -->
    <div class="layui-body layui-form">
        <div class="layui-tab mag0" lay-filter="bodyTab" id="top_tabs_box">
            <ul class="layui-tab-title top_tab" id="top_tabs">
                <li class="layui-this" lay-id=""><i class="layui-icon">&#xe68e;</i> <cite>后台首页</cite></li>
            </ul>
            <ul class="layui-nav closeBox">
                <li class="layui-nav-item">
                    <a href="javascript:;"><i class="layui-icon caozuo">&#xe643;</i> 页面操作</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" class="refresh refreshThis"><i class="layui-icon">&#x1002;</i> 刷新当前</a></dd>
                        <dd><a href="javascript:;" class="closePageOther"><i class="seraph icon-prohibit"></i> 关闭其他</a></dd>
                        <dd><a href="javascript:;" class="closePageAll"><i class="seraph icon-guanbi"></i> 关闭全部</a></dd>
                    </dl>
                </li>
            </ul>
            <div class="layui-tab-content clildFrame" style="margin-top: 20px">
                <div class="layui-tab-item layui-show">
                    <iframe src="http://nows.fun/"></iframe>
                </div>
            </div>
        </div>
    </div>
    <!-- 底部 -->
    <div class="layui-footer footer">
        <p><span>copyright @2020 2019</span></p>
    </div>
</div>
<%--  layui的js  --%>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/layui/layui.js"></script>
<%-- 首页js  页面的渲染 --%>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/index.js"></script>
<%-- 缓存js  左侧菜单的 打开后的选项卡 --%>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/cache.js"></script>

<script>
    layui.use(['jquery','layer','form',],function() {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;

        var payMentNotice = $("#payMentNotice");
        var noticeState = true;// 表示首次通知
        var count = 0;  //表示当前待处理的总数据条数
        var sum = 0;//表示当前数据的ID的总和

	var role = '${user.id}';
        if (role == 1){
            window.setInterval(getPayMentNotice,5000);
        }
        function getPayMentNotice(){
            $.get("${pageContext.request.contextPath}/bussi/payment/uncheckCount.do",function (rs) {
                if(rs.code != 200){
                    layer.msg(rs.msg);
                    return false;
                }
                var data = rs.data;
                if(noticeState){
                    noticeState = false;
                    count = data.count;
                    sum = data.sum;
                    payMentNotice.html(count);
                    if(data.count > 0){
                       var msg = "您当前有" + count + "条待审核缴费记录需要处理";
                       layer.alert(msg,function (index) {
                           layer.close(index);
                       })
                    }
                } else {
                    payMentNotice.html(data.count);
                    if(data.count > 0){
                        if(data.count != count || data.sum != sum) {
                            var msg = "您当前有" + data.count + "条待审核缴费记录需要处理";
                            layer.alert(msg, function (index) {
                                layer.close(index);
                            })
                        }
                    }
                    count = data.count;
                    sum = data.sum;
                }
            });
        }

        $("#changePassword").click(function () {
            layer.open({
                title: '修改密码',
                type: 1,
                content: $("#editTpl").html(),
                area: ['340px', '300px'],
                success:function (layero,index) {
                    form.render();
                    form.on('submit(submitBtnFilter)',function (d) {
                        var param = d.field;
                        var newPassword = param.newPassword;
                        var confirmPassword = param.confirmPassword;
                        if(newPassword != confirmPassword){
                            layer.tips('输入密码不一致!', '#confirmPassword');
                            return false;
                        }
                        $.post("${pageContext.request.contextPath}/comp/user/updatePwd.do",param,function (rs) {
                            if (rs.code != 200){
                                layer.msg(rs.msg);
                                return false;
                            }
                            layer.msg('密码修改成功，三秒后重新登陆！',{
                                time:3000,
                                end:function (){
                                    location.href="${pageContext.request.contextPath}/index.html";
                                }
                            })
                        });
                        return false;
                    });
                },
                btn: ['确认', '取消'],
                btnAlign: 'c',
                yes:function (index,layero) {
                    $("#submitBtn").click();
                }
            });
        });

        $("#signOut").click(function () {
            var result = confirm("确定要退出吗？");
            if(result){
                $.get("${pageContext.request.contextPath}/comp/user/tologout.do",function (rs) {
                    location.href="${pageContext.request.contextPath}/index.html";
                });
            }
        });

    })
</script>
</body>
</html>